package csu.softwaremetric.controller;

import com.alibaba.fastjson.JSONObject;
import csu.softwaremetric.service.ChatService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;

@Controller
public class ChatController {

    @Autowired
    private ChatService chatService;

    @PostMapping(value = "/chat/CK")
    public ResponseEntity<JSONObject> getCKMetricChat(@RequestParam("CKResult") String CKResult)
    {
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("STATUS", "SUCCESS");
        jsonObject.put("MSG", chatService.getCKMetricChat(CKResult));
        return new ResponseEntity<>(jsonObject, HttpStatus.OK);
    }

    //chat功能点度量结果分析
    @PostMapping(value = "/chat/FA")
    public ResponseEntity<JSONObject> getFAMetricChat(@RequestParam("FAResult") String FAResult)
    {
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("STATUS", "SUCCESS");
        jsonObject.put("MSG", chatService.getFunctionMetricChat(FAResult));
        return new ResponseEntity<>(jsonObject, HttpStatus.OK);
    }
    //chat用例点度量结果分析
    @PostMapping(value = "/chat/UCA")
    public ResponseEntity<JSONObject> getUCAMetricChat(@RequestParam("UCAResult") String UCAResult)
    {
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("STATUS", "SUCCESS");
        jsonObject.put("MSG", chatService.getUseCaseMetricChat(UCAResult));
        return new ResponseEntity<>(jsonObject, HttpStatus.OK);
    }

    @PostMapping(value = "/chat/McCabe")
    public ResponseEntity<JSONObject> getUCAMetricChat(@RequestParam("McCabeResult") String McCabeResult,
                                                       @RequestParam("XMLName") String xmlName)
    {
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("STATUS", "SUCCESS");
        jsonObject.put("MSG", chatService.getMcCabeChat(McCabeResult, xmlName));
        return new ResponseEntity<>(jsonObject, HttpStatus.OK);
    }
}
